﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using BLL;
using DAL;
using Models;
using System.Data;
using Web.Old_App_Code;


public partial class alipay_alipayto : System.Web.UI.Page
{

    protected GroupBuyOrderDetailManager gbodm = new GroupBuyOrderDetailManager();
    protected GroupBuyOrderManager gbom = new GroupBuyOrderManager();
    protected GoodsEntitysSpecificationsManager gesm = new GoodsEntitysSpecificationsManager();

    protected OrderGoodsEntitysManager ogem = new OrderGoodsEntitysManager();
    protected OrderManager om = new OrderManager();

    // Methods
    protected void Page_Load(object sender, EventArgs e)
    {
        AlipayConfig config = new AlipayConfig();
        string partner = config.Partner;
        string key = config.Key;
        string str3 = config.Seller_email;
        string str4 = config.Input_charset;
        string str5 = config.Notify_url;
        string str6 = config.Return_url;
        string str7 = config.Show_url;
        string str8 = config.Sign_type;
        string str9 = "";
        string subject = "";
        string body = "";
        string str12 = "";
        if ((base.Request.QueryString["orderNo"] != null) && (base.Request.QueryString["pay_bank"] != null))
        {
            if (base.Request.QueryString["orderNo"].Contains("PM_"))
            {
                DataRow row = this.om.GetOrderByOrderNo(base.Request.QueryString["orderNo"]).Rows[0];
                str9 = row["orderNo"].ToString();
                subject = "在线支付";
                DataTable orderGoodsEntitysByOrderNo = this.ogem.GetOrderGoodsEntitysByOrderNo(base.Request.QueryString["orderNo"]);
                foreach (DataRow row2 in orderGoodsEntitysByOrderNo.Rows)
                {
                    object obj2;
                    body = body + " [" + row2["goodsName"].ToString() + " ";
                    DataTable table3 = this.gesm.FrontDeskGetGoodsEntitysSpecificationsByGoodsEntitys(Convert.ToInt32(row2["goodsEntitys"]));
                    for (int i = 0; i < table3.Rows.Count; i++)
                    {
                        obj2 = body;
                        body = string.Concat(new object[] { obj2, (i > 0) ? " " : "", table3.Rows[i]["specificationsName"], "：", table3.Rows[i]["specificationsValueName"] });
                    }
                    obj2 = body;
                    body = string.Concat(new object[] { obj2, " 数量：", row2["amount"], "]" });
                }
                str12 = row["orderTotal"].ToString();
            }
            else if (base.Request.QueryString["orderNo"].Contains("GB_"))
            {
                DataRow row3 = this.gbom.GetGroupBuyOrderByOrderNo(base.Request.QueryString["orderNo"]).Rows[0];
                str9 = row3["orderNo"].ToString();
                subject = "商品团购在线支付";
                body = "商品团购在线支付";
                str12 = row3["orderTotal"].ToString();
            }
        }
        else
        {
            str9 = DateTime.Now.ToString("yyyyMMddHHmmssffffff");
            subject = base.Request.Form["aliorder"];
            body = base.Request.Form["alibody"];
            str12 = base.Request.Form["alimoney"];
        }
        string paymethod = "";
        string defaultbank = "";
        string str15 = "";
        if ((base.Request.QueryString["orderNo"] != null) && (base.Request.QueryString["pay_bank"] != null))
        {
            str15 = base.Request.QueryString["pay_bank"];
        }
        else
        {
            str15 = base.Request.Form["pay_bank"];
        }
        if (str15 == "directPay")
        {
            paymethod = "directPay";
        }
        else
        {
            paymethod = "bankPay";
            defaultbank = str15;
        }
        string str16 = "";
        string str17 = "";
        string str18 = "";
        string str19 = "";
        string str20 = "";
        string str21 = "";
        string str22 = new AlipayService(partner, str3, str6, str5, str7, str9, subject, body, str12, paymethod, defaultbank, str16, str17, str18, str19, str20, str21, key, str4, str8).Build_Form();
        this.lbOut_trade_no.Text = str9;
        this.lbTotal_fee.Text = str12;
        this.lbButton.Text = str22;
    }

}